let userDao = require('../dao/userDao');
let tokenUtil = require('../token');
let bcryptUtil = require('../util/bcryptUtil');
let md5 = require('md5');

let ss = module.exports;

ss.f = async function () {
    let users = await userDao.queryUsers();
    for (let i = 0; i < users.length; i++) {
        let user = users[i];
        let decodeStr = tokenUtil.aesDecodeDef(user.password);
        if (decodeStr && decodeStr !== null && decodeStr !== 'null'){
            let md5Str = md5(decodeStr);
            let pwd = bcryptUtil.hash(md5Str);
            console.log(pwd);
            await userDao.updateUserPassword(user.uid, pwd);
        }
    }
};